package com.ruoyi.eqmonitor.smdtv.controller;

import java.util.List;

import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.common.core.web.page.TableSupport;
import com.ruoyi.eqmonitor.smdtv.domain.Smdtv10;
import com.ruoyi.eqmonitor.smdtv.service.ISmdtv10Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.Arrays;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.security.utils.SecurityUtils;

import com.ruoyi.common.core.web.page.TableDataInfo;

@Api(tags = "溢流井")
@RestController
@RequestMapping("/smdtv10")
public class Smdtv10Controller extends BaseController{

    @Autowired
    private ISmdtv10Service smdtv10Service;

    /**
     * 获取溢流井列表
     */
    @GetMapping("/list")
    public TableDataInfo<?> list(Smdtv10 smdtv10){
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        List<Smdtv10> list = smdtv10Service.selectSmdtv10List(smdtv10,(pageNum - 1) * pageSize,pageSize);
        return getDataTable2(list,smdtv10Service.getTotal(smdtv10));
    }

    /**
     * 获取全部溢流井
     */
    @GetMapping("/all")
    public AjaxResult getAll(){
        return AjaxResult.success(smdtv10Service.getAll());
    }

    /**
     * 根据id获取溢流井
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return AjaxResult.success(smdtv10Service.selectSmdtv10ById(id));
    }

    /**
     * 新增溢流井
     */
    @Log(title = "新增溢流井", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Smdtv10 smdtv10){
        return toAjax(smdtv10Service.save(smdtv10));
    }

    /**
     * 修改溢流井
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Smdtv10 smdtv10){
        return toAjax(smdtv10Service.updateById(smdtv10));
    }

    /**
     * 传入@PathVariable的格式类似为/1,2,3,4,5时,会自动转为数组
     */
    @Log(title = "删除溢流井", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(smdtv10Service.removeByIds(Arrays.asList(ids)));
    }

    /**
     * 导出溢流井列表
     */
    @Log(title = "导出溢流井列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Smdtv10 smdtv10){
        List<Smdtv10> list = smdtv10Service.selectSmdtv10List(smdtv10,null,null);
        ExcelUtil<Smdtv10> util = new ExcelUtil<Smdtv10>(Smdtv10.class);
        util.exportExcel(response, list, "溢流井数据");
    }

    /**
     * 溢流井树状图
     */
    @ApiOperation("树状图")
    @GetMapping(value = "/treeMap")
    public AjaxResult treeMap(){
        return AjaxResult.success(smdtv10Service.treeMap());
    }
    
}
